<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Scrollview List Plugin Tests</title>
<script type="text/javascript" src="../../../../build/yui/yui.js"></script>
</head>

<body class="yui3-skin-sam">
<h1>Scrollview List Plugin Tests</h1>
<p>
	        <div class="header">
	        	<h1>Scrollview 1</h1>
	        </div>
	        <div id="scrollable1" class="yui3-scrollview-loading">
	            <ul>
	    			<li>
	    				<div>I am a div with some LI content inside me!
	                        <ul>
	                            <li class="special">LI content 1</li>
	                            <li class="special">LI Content 2</li>
	                            <li class="special">LI Content 3</li>
	                        </ul>
	                    </div>
	    			</li>
	    			<li>
	    				<div>Purchased</div>
	    			</li>
	    			<li>
	    				<div>Air</div>
	    			</li>
	    			<li>
	    				<div>Amelie</div>
	    			</li>
	    			<li>
	    				<div>Ben Folds</div>
	    			</li>
	    			<li>
	    				<div>Ben Harper</div>
	    			</li>
	    			<li>
	    				<div>Blue October</div>
	    			</li>
	    			<li>
	    				<div>Bob Dylan</div>
	    			</li>
	    			<li>
	    				<div>Cake</div>
	    			</li>
	    			<li>
	    				<div>Citizen Cope</div>
	    			</li>
	    			<li>
	    				<div>Coldplay</div>
	    			</li>
	    			<li>
	    				<div>Dido</div>
	    			</li>
	                <li>
	                    <div>I am a div with some LI content inside me!
	                        <ul>
	                            <li class="special">LI content 1</li>
	                            <li class="special">LI Content 2</li>
	                            <li class="special">LI Content 3</li>
	                        </ul>
	                    </div>
	                </li>
	    			<li>
	    				<div>Lily Allen</div>
	    			</li>
	    			<li>
	    				<div>Purchased on the iPhone</div>
	    			</li>
	    			<li>
	    				<div>Purchased</div>
	    			</li>
	    			<li>
	    				<div>Air</div>
	    			</li>
	    			<li>
	    				<div>Amelie</div>
	    			</li>
	    			<li>
	    				<div>Ben Folds</div>
	    			</li>
	    			<li>
	    				<div>Ben Harper</div>
	    			</li>
	                <li>
	                    <div>I am a div with some LI content inside me!
	                        <ul>
	                            <li class="special">LI content 1</li>
	                            <li class="special">LI Content 2</li>
	                            <li class="special">LI Content 3</li>
	                        </ul>
	                    </div>
	                </li>
	    			<li>
	    				<div>Bob Dylan</div>
	    			</li>
	    			<li>
	    				<div>Cake</div>
	    			</li>
	    			<li>
	    				<div>Citizen Cope</div>
	    			</li>
	    			<li>
	    				<div>Coldplay</div>
	    			</li>
	    			<li>
	    				<div>Dido</div>
	    			</li>
	    			<li>
	    				<div>Foo Fighters</div>
	    			</li>
	    			<li>
	    				<div>Lily Allen</div>
	    			</li>

	            </ul>
	        </div>


	            <div class="header">
	            	<h1>Scrollview 2 - has divs as immediate children</h1>
	            </div>
	            <div id="scrollable2" class="yui3-scrollview-loading">
	        			<div>
	        				<div>I am a div with some LI content inside me!
	                            <ul>
	                                <li>LI content 1</li>
	                                <li>LI Content 2</li>
	                                <li>LI Content 3</li>
	                            </ul>
	                        </div>
	        			</div>

	                    <div>
	                        <div>I am a div with some LI content inside me!
	                            <ul>
	                                <li>LI content 1</li>
	                                <li>LI Content 2</li>
	                                <li>LI Content 3</li>
	                            </ul>
	                        </div>
	                    </div>
	        			<div>
	        				<div>Lily Allen</div>
	        			</div>
	        			<div>
	        				<div>Purchased on the iPhone</div>
	        			</div>
	        			<div>
	        				<div>Purchased</div>
	        			</div>
	        			<div>
	        				<div>Air</div>
	        			</div>
	        			<div>
	        				<div>Amelie</div>
	        			</div>
	        			<div>
	        				<div>Ben Folds</div>
	        			</div>
	        			<div>
	        				<div>Ben Harper</div>
	        			</div>
	                    <div>
	                        <div>I am a div with some LI content inside me!
	                            <ul>
	                                <li>LI content 1</li>
	                                <li>LI Content 2</li>
	                                <li>LI Content 3</li>
	                            </ul>
	                        </div>
	                    </div>
	        			<div>
	        				<div>Bob Dylan</div>
	        			</div>
	        			<div>
	        				<div>Cake</div>
	        			</div>
	        			<div>
	        				<div>Citizen Cope</div>
	        			</div>
	        			<div>
	        				<div>Coldplay</div>
	        			</div>
	        			<div>
	        				<div>Dido</div>
	        			</div>
	        			<div>
	        				<div>Foo Fighters</div>
	        			</div>
	        			<div>
	        				<div>Lily Allen</div>
	        			</div>

	            </div>



</p>

<script type="text/javascript">
(function() {
    YUI({
        filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'raw',
        coverage: ['scrollview-list']
    }).use("test-console", "test", "dump", "scrollview-base", 'scrollview-list', function(Y) {


        // Set up the page
        var ASSERT = Y.Assert,
            ARRAYASSERT = Y.ArrayAssert;

		new Y.Test.Console().render();

        var testBasic = new Y.Test.Case({
            name: "API Tests",

			svCfg1: {
			    contentBox: '#scrollable1',
			    height: 372,
			    width: 400,
			    flick : {
			        minDistance:0,
			        minVelocity:0
			    },
			    plugins: [Y.Plugin.ScrollViewList]
			},

			svCfg2: {
			    contentBox: '#scrollable2',
			    height: 372,
			    width: 400,
			    flick : {
			        minDistance:0,
			        minVelocity:0
			    },
			    plugins: [Y.Plugin.ScrollViewList]
			},

		    //---------------------------------------------
		    // Setup and tear down
		    //---------------------------------------------

		    setUp : function () {

		    },

		    tearDown : function () {

		    },


			//---------------------------------------------
		    // Instantiation
		    //---------------------------------------------

		    //makes sure only immediate decendant LI and UL's are selected
			testBasicScrollviewList: function() {

				var sv = new Y.ScrollView(this.svCfg1),
				cb, id, ul, li, className, special;

				sv.render();

				cb = sv.get('contentBox');
				id = cb.get('id');

				ul = Y.all('#'+ id +' > ul')
				li = Y.all('#'+ id +' > ul > li');
				special = Y.all('.special');

				ul.each(function(item) {
					className = item.getAttribute('class');
					Y.log('checked ul');
					Y.Assert.areEqual("yui3-scrollview-list", className, "List Class name not equal");
				});

				li.each(function(item) {
					className = item.getAttribute('class');
					Y.log('checked li');
					Y.Assert.areEqual("yui3-scrollview-item", className, "Item Class name not equal");
				});

				special.each(function(item) {
					Y.log('checked specials');
					Y.Assert.isFalse(item.hasClass('yui3-scrollview-item'), "Special LIs should not have class");
				});

			},

			testScrollviewListWithDiv: function() {
				var sv = new Y.ScrollView(this.svCfg2),
				cb, id, li;

				cb = sv.get('contentBox');
				id = cb.get('id');

				li = Y.all('#' + id + ' li');

				li.each(function(item) {
					Y.log('checked li');
					Y.Assert.isFalse(item.hasClass('yui3-scrollview-item'), "these LIs should not have class because they are not immediate decendants");

				});



			}

        });

        var suite = new Y.Test.Suite("Scrollview: List");
        suite.add(testBasic);

        Y.Test.Runner.add(suite);
        Y.Test.Runner.run();
    });
})();
</script>
</body>
</html>
